package top.linyuxb.lycloud.admin.repository;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import top.linyuxb.lycloud.admin.entity.LyCloudUserEntity;

/**
 * Created by Intellij IDEA.
 *
 * @Author: linyuxb
 * @Date: 2024/7/29 15:16
 * @Desc:
 */
@Repository
public interface LyCloudUserRepository extends BaseRepository<LyCloudUserEntity, Long> {
    /**
     * 用户查询
     *
     * @param username
     * @return
     */
    LyCloudUserEntity findByUsername(String username);

    /**
     * 用户删除
     *
     * @param username
     * @return
     */
    @Modifying
    @Transactional
    @Query(value = "UPDATE ly_cloud_user SET status = 0 WHERE username = ?1 and status = 1", nativeQuery = true)
    Integer deleteByUsername(String username);
}
